package com.hitrust.gs.action;

import java.util.ArrayList;

import com.hitrust.gs.bean.GSProviderBean;
import com.hitrust.gs.business.GSProviderProcessor;
import com.hitrust.gs.form.GSProviderScanQueryForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSSystemConfigurator;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.service.GSBaseManager;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.util.page.ResultProcess;

/**
 * 查询供应商操作
 */
public class GSProviderScanQueryAction extends GSBaseAction {


    public String execute(GSBaseForm aForm) throws Exception {
        
        GSProviderScanQueryForm tForm = (GSProviderScanQueryForm)aForm;
        //取得页面参数组成Bean对象
        GSProviderBean tGSProviderBean = new GSProviderBean();
        //tGSProviderBean.setGs_provider_id(tForm.getProviderId());
        tGSProviderBean.setGs_provider_name(tForm.getProviderName());
        tGSProviderBean.setGs_reside_country(tForm.getCountryCode());
        tGSProviderBean.setGs_reside_province(tForm.getProvinceCode());
        tGSProviderBean.setGs_reside_city(tForm.getDistrictCode());
        //tGSProviderBean.setGs_corp_property(tForm.getCorpProperty());
        tGSProviderBean.setGs_contact_id(tForm.getContactid());
        tGSProviderBean.setGs_contact_phone(tForm.getContactphone());
        if( GSSystemConfigurator.getInstance().getProjectVersionType().equals("SH")){
            tGSProviderBean.setGs_validity(tForm.getStatus()); 
        }
        tGSProviderBean.setIs_audit(tForm.getIsAudit());
        
        try{
            //查询供应商
            GSProviderProcessor tGSProviderProcesser = new GSProviderProcessor();
            ResultProcess tRp = tGSProviderProcesser.getProviderByOpt(tGSProviderBean);
            tForm.getRequest().setAttribute("provider",tRp);
            
            //取得所有国家
            ArrayList tList = GSBaseManager.getAllCountry();
            aForm.getRequest().setAttribute("country",tList);
            //取得所有省
            tList = GSBaseManager.getAllProvince();
            aForm.getRequest().setAttribute("province",tList);
            //取得所有地区
            tList = GSBaseManager.getAllDistinct();
            aForm.getRequest().setAttribute("district",tList);
            //取得公司性质
            String[][] tStr= GSBaseManager.getAllCorpProperty();
            aForm.getRequest().setAttribute("corpproperty",tStr);
            aForm.getRequest().setAttribute("requery","false");
        }catch(GSException e){
            aForm.getRequest().setAttribute("action", "A200201.do");
            throw e;
        }
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
